package com.lzb.permanentcalendar.utils;

import android.app.Activity;

import com.lzb.permanentcalendar.bean.SxBean;
import com.nlf.calendar.Holiday;
import com.nlf.calendar.Lunar;
import com.nlf.calendar.Solar;
import com.nlf.calendar.util.HolidayUtil;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class DataListUtils {


    public static List<SxBean> getSxList() {
        List<SxBean> gifResIds = new ArrayList<>();
        for (int i = 1; i <= 12; i++) {
            String sx = "";
            if (i == 1) {
                sx = "鼠";
            } else if (i == 2) {
                sx = "牛";
            } else if (i == 3) {
                sx = "虎";
            } else if (i == 4) {
                sx = "兔";
            } else if (i == 5) {
                sx = "龙";
            } else if (i == 6) {
                sx = "蛇";
            } else if (i == 7) {
                sx = "马";
            } else if (i == 8) {
                sx = "羊";
            } else if (i == 9) {
                sx = "猴";
            } else if (i == 10) {
                sx = "鸡";
            } else if (i == 11) {
                sx = "狗";
            } else if (i == 12) {
                sx = "猪";
            }
            gifResIds.add(new SxBean(sx, false));
        }
        return gifResIds;
    }

    public static List<Integer> getYearsByShengXiao(String targetShengXiao, int startYear, int endYear) {
        List<Integer> years = new ArrayList<>();
        for (int year = startYear; year <= endYear; year++) {
            try {
                // 使用每年6月1日的公历日期，确保已过农历新年
                Solar solar = Solar.fromYmd(year, 6, 1);
                Lunar lunar = solar.getLunar();
                String sx = lunar.getYearShengXiao();
                if (targetShengXiao.equals(sx)) {
                    years.add(year);
                }
            } catch (Exception e) {
                // 处理可能的无效日期（理论上不会触发）
                System.err.println("日期转换异常：" + e.getMessage());
            }
        }
        return years;
    }

    public static String getShengXiaoByYear(int year) {
        try {
            // 使用6月1日确保已过农历新年
            Solar solar = Solar.fromYmd(year, 6, 1);
            Lunar lunar = solar.getLunar();
            return lunar.getYearShengXiao();
        } catch (Exception e) {
            // 处理非法年份（如：负数或超大值）
            return "";
        }
    }


}
